﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StudentMgmt.IDAL;
using StudentMgmt.Model;
using StudentMgmt.Model.DataContext;

namespace StudentMgmt.SQLServerDAL
{
    public class Classes : IClasses
    {
        public ClassInfo GetClass(string class_id)
        {
            StudentMgmtDataContext db = new StudentMgmtDataContext();
            var oclass = db.Classes.Single(c => c.ClassId == class_id);

            return oclass;

        }

        public IList<ClassInfo> GetClasses()
        {
            StudentMgmtDataContext db = new StudentMgmtDataContext();
            var classes = from c in db.Classes
                          select c;

            return classes.ToList();
        }

        public IList<ClassInfo> GetClassesByDeptId(string dept_id)
        {
            StudentMgmtDataContext db = new StudentMgmtDataContext();
            var classes = from c in db.Classes
                         where c.DepartmentId == dept_id
                         select c;

            return classes.ToList();
        }
    }
}
